import { HttpProvider } from './../http/http';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

/*
  Generated class for the BusiProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class BusiProvider {

  constructor(public http: HttpClient, private httpservice: HttpProvider) {
    console.log('Hello BusiProvider Provider');
  }

  login(username, password) {
    let param = {
      "userName": username,
      "password": password
    }
    return this.httpservice.postLoading("authen/getToken", param);
  }

  getUserInfo() {
    return this.httpservice.postNoloading("user/getUserinfo");
  }
  passwordchange(passwordold, passwordnew) {
    let param = {
      "passwordold": passwordold,
      "passwordnew": passwordnew
    }
    return this.httpservice.postLoading("user/changeCurrentPassword", param);
  }
  appUserModify(body) {
    return this.httpservice.postLoading("user/useredit", null, body);
  }
  validatePassword(password) {
    let param = {
      "password": password
    }
    return this.httpservice.postLoading("user/validatePassword", param);
  }
  getVersion() {
    let param = {
      "app": "hms_mobile"
    }
    return this.httpservice.postNoloading("version/getVersion", param);
  }
  register(body){
    return this.httpservice.postLoading("parent/addParent",null,body);
  }
  updateimg(url){
    const param={
      imgurl:url
    }
    return this.httpservice.postLoading("parent/updateImage",param);

  }
  shopAdd(body){
    return this.httpservice.postLoading("shop/shopAdd",null,body);
  }

  getMyOrders(){
    return this.httpservice.postLoading("order/getMyorders");
  }
  userAdd(body){
    return this.httpservice.postLoading("user/useradd",null,body);
  }

  getAllSchools(){
    return this.httpservice.postLoading("school/getAllSchools");
  }

  getMyShopBus(){
    return this.httpservice.postLoading("shopbus/getMyShopBus");
  }
  getProduct(type){
    let params ={
      type:type
    }
    return this.httpservice.postLoading("product/getProducts",params);
  }

  getProductDetail(prodid){
    let params ={
      prodid:prodid
    }
    return this.httpservice.postLoading("product/getProductDetail",params);
  }
  addToShopBus(productid){
    let params ={
      productid:productid
    }
    return this.httpservice.postLoading("shopbus/addToShopBus",params);
  }

  buyProduct(productid){
    let params ={
      productid:productid
    }
    return this.httpservice.postLoading("myorder/buyProduct",params);
  }
  getComment(productid){
    let params ={
      prodid:productid
    }
    return this.httpservice.postLoading("productcomment/getComment",params);
  }
  addComment(prodid,content){
    let params ={
      prodid:prodid,
      content:content
    }
    return this.httpservice.postLoading("productcomment/addComment",params);
  }

  buyFromShopBus(body){
    return this.httpservice.postLoading("shopbus/buyFromShopBus",null,body);
  }
  addEmail(body){
    return this.httpservice.postLoading("email/addEmail",null,body);
  }
  getMyProduct(){
    return this.httpservice.postLoading("product/getMyProduct");
  }

  sxjPro(body){
    return this.httpservice.postLoading("product/sxjPro",null,body);

  }

  addProd(body){
    return this.httpservice.postLoading("product/addProd",null,body);
  }

  getProductWsh(){
    return this.httpservice.postLoading("product/getProductWsh");
  }
  shProduct(param){
    return this.httpservice.postLoading("product/shProduct",param);
  }
  getWshShops(){
    return this.httpservice.postLoading("shop/getWshShops");
  }
  shopSh(para){
    return this.httpservice.postLoading("shop/shopSh",para);
  }
  getAllUsers(){
    return this.httpservice.postLoading("user/getAllUsers");
  }
}
